import java.util.HashSet;
import java.util.Iterator;

public class IteratorErrorTest {
    public static void main(String[] args) {
        // 创建一个集合
        HashSet books = new HashSet();
        books.add("Java集合");
        books.add("数据结构与算法");
        books.add("Java从入门到精通");
        Iterator it = books.iterator();
        while (it.hasNext()) {
            String book = (String)it.next();
            System.out.println(book);
            if (book.equals("Java从入门到精通")) {
                books.remove(book);
            }
        }
    }
}
